package rad.framework.mda.generator.template.test.java.service;

import java.util.*;
import rad.framework.mda.generator.util.*;
import org.eclipse.emf.codegen.util.*;

public class JpaJUnit
{
  protected static String nl;
  public static synchronized JpaJUnit create(String lineSeparator)
  {
    nl = lineSeparator;
    JpaJUnit result = new JpaJUnit();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = "package ";
  protected final String TEXT_2 = ";";
  protected final String TEXT_3 = NL;
  protected final String TEXT_4 = NL + NL + "/**" + NL + " * Unit tests for the ";
  protected final String TEXT_5 = "." + NL + " *" + NL + " * @author ";
  protected final String TEXT_6 = NL + " * @generated" + NL + " */" + NL + "public class ";
  protected final String TEXT_7 = "Test extends JpaCrudTest<";
  protected final String TEXT_8 = "> {" + NL + "" + NL + "\t/** @generated */" + NL + "\tpublic ";
  protected final String TEXT_9 = "Test(String name) {" + NL + "\t\tsuper(name);" + NL + "\t}" + NL + "" + NL + "\t/** @generated */" + NL + "\tpublic static Test suite() {" + NL + "\t\tTestSuite suite = new TestSuite();" + NL + "\t\tsuite.addTest(new ";
  protected final String TEXT_10 = "Test(\"testCrud\"));" + NL + "\t\treturn new Bootstrap(suite);" + NL + "\t}" + NL + "" + NL + "\t/** @generated */" + NL + "\tprotected void initData(EntityManager em) throws Exception {" + NL + "\t}" + NL + "    " + NL + "\t/** @generated */" + NL + "\tprotected void prePersist(EntityManager em) throws Exception {" + NL + "\t\tentity = new ";
  protected final String TEXT_11 = "();" + NL + "\t\t// TODO setup entity" + NL + "\t}    " + NL + "    " + NL + "\t/** @generated */" + NL + "\tprotected void preMerge(EntityManager em) throws Exception {" + NL + "\t\t// TODO change entity" + NL + "\t}    " + NL + "    " + NL + "\t/** @generated */" + NL + "\tprotected void postMerge(EntityManager em) throws Exception {" + NL + "\t\t// TODO change entity" + NL + "\t}    " + NL + "    " + NL + "\t/** @generated */" + NL + "\tprotected void preRemove(EntityManager em) throws Exception {" + NL + "\t\t// TODO dis-associate" + NL + "\t}    " + NL + "}";
  protected final String TEXT_12 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
    

    org.eclipse.uml2.uml.Class uml2Class = (org.eclipse.uml2.uml.Class) argument;org.eclipse.uml2.uml.Package uml2Package = uml2Class.getPackage();
    ImportManager importManager=null;
    if (NameHelper.getQualifiedName(uml2Package) != null) {
    importManager = ImportHelper.makeImportManager(NameHelper.getQualifiedName(uml2Package));
    stringBuffer.append(TEXT_1);
    stringBuffer.append(NameHelper.getQualifiedName(uml2Package));
    stringBuffer.append(TEXT_2);
    } else {
    importManager = ImportHelper.makeImportManager("");
    }
    stringBuffer.append(TEXT_3);
    importManager.addImport("javax.persistence.EntityManager");
    importManager.addImport("junit.framework.Test");
    importManager.addImport("junit.framework.TestSuite");
    importManager.addImport("rad.framework.embedded.Bootstrap");
    importManager.addImport("rad.framework.testing.JpaCrudTest");
    
StringBuffer importStringBuffer = stringBuffer;
int importInsertionPoint = stringBuffer.length();
importManager.addCompilationUnitImports(stringBuffer.toString());

    stringBuffer.append(TEXT_4);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_5);
    stringBuffer.append(System.getProperty("user.name"));
    stringBuffer.append(TEXT_6);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_7);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_8);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_9);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_10);
    stringBuffer.append(NameHelper.getCapName(uml2Class));
    stringBuffer.append(TEXT_11);
    importStringBuffer.insert(importInsertionPoint, importManager.computeSortedImports());
    stringBuffer.append(TEXT_12);
    return stringBuffer.toString();
  }
}
